<%@ Page Language="VB" StylesheetTheme="default"  MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="InstrumentDetail.aspx.vb" Inherits="Modules_Questionnaires_InstrumentDetail" title="Instrument Detail Page" %>
<%@ Register Assembly="DotNetPM.Web.UI.WebControls" TagPrefix="cc" Namespace="DotNetPM.Web.UI.WebControls" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

    <div>
        <table id="Table1" border="0" cellpadding="2" cellspacing="2" width="100%">
            <tr>
                <td colspan="4">
                    <strong><font size="2">INSTRUMENT DETAIL</font></strong></td>
                <td align="right" colspan="1">
                    <asp:HyperLink ID="hlBack" runat="server" NavigateUrl="InstrumentManager.aspx" ForeColor="Blue">Back</asp:HyperLink></td>
            </tr>
            <tr style="color: #000000">
                <td colspan="5">
                    <hr size="1" width="100%" />
                </td>
            </tr>
            <tr>
                <td rowspan="5" valign="top" width="15">&nbsp;</td>
                <td valign="top" colspan="2" style="height: 20px">
                    <asp:DetailsView ID="dvInstrument" runat="server" DataSourceID="InstrumentDS"
                        Height="50px" Width="800px" AutoGenerateRows="False" DataKeyNames="InstrumentID">
                        <Fields>
                            <asp:TemplateField HeaderText="Instrument ID" SortExpression="InstrumentID">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox1" runat="server" MaxLength=50  width="500px" Text='<%# Bind("InstrumentID") %>' Enabled='<%# not eval("Locked") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("InstrumentID") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Name" SortExpression="Name">
                                <EditItemTemplate>
                                    <cc:counttextbox id="counttextbox2" runat="server" maxlength="250" rows="2" text='<%# Bind("Name") %>' textmode="MultiLine" width="500px"></cc:counttextbox>
                                 </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Description" SortExpression="Description">
                                <EditItemTemplate>
                                    <cc:counttextbox id="counttextbox3" runat="server" maxlength="1000" rows="4" text='<%# Bind("Description") %>' textmode="MultiLine" width="500px"></cc:counttextbox>
                                 </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Instruction" SortExpression="Instruction" InsertVisible="False">
                                <EditItemTemplate>
                                    <cc:counttextbox id="counttextbox4" runat="server" maxlength="1000" rows="6" text='<%# Bind("Instruction") %>' textmode="MultiLine" width="500px"></cc:counttextbox>
                                 </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("Instruction") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="CreatedDate" HeaderText="Created Date" ReadOnly="True"
                                SortExpression="CreatedDate" InsertVisible="False" />
                            <asp:BoundField DataField="LastUpdated" HeaderText="Last Updated" ReadOnly="True"
                                SortExpression="LastUpdated" InsertVisible="False" />
                            <asp:CommandField ShowEditButton="True" />
                        </Fields>
                    </asp:DetailsView>
                    <asp:ObjectDataSource ID="InstrumentDS" runat="server" OldValuesParameterFormatString="original_{0}"
                        SelectMethod="GetInstrument" TypeName="DotNetPM.Business.Questionnaire.InstrumentODS" UpdateMethod="UpdateInstrument">
                        <SelectParameters>
                            <asp:SessionParameter Name="instrumentId" SessionField="questionnaire_instrumentId"
                                Type="String" />
                        </SelectParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="instrumentId" Type="String" />
                            <asp:Parameter Name="name" Type="String" />
                            <asp:Parameter Name="description" Type="String" />
                            <asp:Parameter Name="instruction" Type="String" />
                            <asp:Parameter Name="original_instrumentId" Type="String" />
                        </UpdateParameters>
                    </asp:ObjectDataSource>
                </td>
                <td colspan="2" valign="top" style="height: 20px">
                </td>
            </tr>
            <tr>
                <td valign="Top" style="height: 2px">
                    <strong><span style="font-size: 10pt">QUESTIONS</span></strong></td>
                <td align="right" valign="bottom" style="height: 2px">
                    <asp:LinkButton ID="lbutNew" runat="server" Font-Bold="True"><SPAN style="POSITION: relative; TOP: -4px; left:-4px">Add A New Logic</SPAN><img src="../../Images/New.gif" style="border-width:0px;POSITION: relative;" /></asp:LinkButton></td>
                <td align="left" colspan="2" rowspan="1" width="300" style="height: 2px">
                </td>
            </tr>
            <tr>
                <td colspan="2" valign="middle" style="height: 40px">
                    <asp:GridView ID="gvQuestions" runat="server" AutoGenerateColumns="False" Width="800px" EmptyDataText="<div align=center>There is no question for this questionnaire.</div>" DataSourceID="QuestionsDS">
                        <Columns>
                            <asp:BoundField DataField="SortID" HeaderText="ID" ReadOnly="True" SortExpression="SortID" >
                                <ItemStyle Width="40px" />
                            </asp:BoundField>
                            <asp:TemplateField HeaderText="Question" SortExpression="Question">
                                <ItemTemplate>
                                    <asp:HiddenField ID="hfGUID" Value='<%# Bind("UID") %>' runat=server />
                                    <asp:HiddenField ID="hfQuestionID" Value='<%# Bind("QuestionID") %>' runat=server /> 
                                    <asp:HiddenField ID="hfEnable" runat="server" Value='<%# Bind("Enabled") %>' />                                   
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Question") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField>
                                <ItemTemplate>                                  
                                    <cc:dynImageButton ID="iButEdit" runat="server" CausesValidation="False" CommandName="SelectQuestion" Visible='<%# IsNotLocked %>'
                                        CommandArgument='<%# Container.DataItemIndex %>' ImageUrl="~/Images/Edit_0.gif" Text="Edit Question" ToolTip="Edit Question" />
                                    <cc:dynImageButton ID="iButLogic" runat="server" CausesValidation="False" CommandName="EditLogic" 
                                        CommandArgument='<%# Container.DataItemIndex %>' ImageUrl="~/Images/Logic_0.gif" Text="Edit Logic" ToolTip="Define Question Logic" />
                                </ItemTemplate>
                                <ItemStyle Width="40px" HorizontalAlign="Center" />
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                    <asp:ObjectDataSource ID="QuestionsDS" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetInstrumentQuestions" TypeName="DotNetPM.Business.Questionnaire.InstrumentODS">
                        <SelectParameters>
                            <asp:SessionParameter Name="instrumentId" SessionField="questionnaire_instrumentId"
                                Type="String" />
                        </SelectParameters>
                    </asp:ObjectDataSource>
                </td>
                <td align="left" colspan="2" rowspan="1" width="300" style="height: 40px">
                    <asp:ImageButton ID="ibutTop" runat="server" ImageUrl="~/Images/Tp.gif"
                        Visible="False" />
                    <asp:ImageButton ID="ibutUp" runat="server" ImageUrl="~/Images/Up.gif"
                        Visible="False" />
                    <asp:ImageButton ID="ibutDown" runat="server" ImageUrl="~/Images/Dn.gif"
                        Visible="False" />
                    <asp:ImageButton ID="ibutButtom" runat="server" ImageUrl="~/Images/Bm.gif"
                        Visible="False" /></td>
            </tr>
            <tr>
                <td align="right" colspan="2" valign="top">
                    <asp:ImageButton ID="ibutBack" runat="server" ImageUrl="~/Images/Back.gif" />
                </td>
                <td colspan="2" valign="top"></td>
            </tr>
            <tr id="trAdd" runat=server visible=false>
                <td colspan="2">
    <a name="editarea" />
                    <table  cellspacing="2" cellpadding="2" border="0" style="background-color:White;border-color:Black;border-width:1px;border-style:Solid;width:800px;">
                        <tr style="color:MistyRose;background-color:#4A3C8C;font-weight:bold;">
                            <td valign="top" align="center">
                            Add New Question</td>
                        </tr>
                        <tr style="color:Black;background-color:#EEEEEE;">
                            <td valign="top">
                                <table border=0 >
                                    <tr>
                                        <td width=100 align="right"> Filter by Category : </td>
                                        <td width=120 >
                                            <asp:DropDownList ID="ddlCategories" runat="server" AppendDataBoundItems="True" DataSourceID="CategoryODS" DataTextField="Name" DataValueField="ID">
                                                <asp:ListItem Selected="True" Value="0">None</asp:ListItem>
                                            </asp:DropDownList>&nbsp;
                                        </td>
                                        <td width=120>
                                            <asp:ObjectDataSource ID="CategoryODS" runat="server" OldValuesParameterFormatString="original_{0}"
                                                SelectMethod="GetCategories" TypeName="DotNetPM.Business.Questionnaire.CategoryODS">
                                            </asp:ObjectDataSource>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="right">Question contains : </td>
                                        <td ><asp:TextBox ID="txtStringToSearch" runat="server"></asp:TextBox></td>
                                        <td>
                                            <asp:Button ID="butSearch" runat="server" Text="Search" Width="60px" />&nbsp;
                                            <asp:Button ID="butClear" runat="server" Text="Clear" Width="60px" /></td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr style="color: black; background-color: #eeeeee">
                            <td align="right" valign="top">
                                <asp:LinkButton ID="lbutCreate" runat="server" Font-Bold="True"><SPAN style="POSITION: relative; TOP: -4px; left:-4px">Create A New Question</SPAN><img src="../../Images/New.gif" style="border-width:0px;POSITION: relative;" /></asp:LinkButton></td>
                        </tr>
                        <tr style="color:Black;background-color:Gainsboro;">
                            <td align="right" valign="top">
                                <asp:ListBox ID="lstQuestions" runat="server" DataSourceID="odsQuestions" DataTextField="Question"
                                    DataValueField="ID" Width="788px" ValidationGroup="Adding"></asp:ListBox>
                                <asp:ObjectDataSource ID="odsQuestions" runat="server"
                                    OldValuesParameterFormatString="original_{0}" SelectMethod="GetQuestions" TypeName="DotNetPM.Business.Questionnaire.QuestionODS">
                                    <SelectParameters>
                                        <asp:ControlParameter ControlID="ddlCategories" Name="CategoryID" PropertyName="SelectedValue"
                                            Type="Int32" />
                                        <asp:ControlParameter ControlID="txtStringToSearch" Name="StringToSearch" PropertyName="Text"
                                            Type="String" />
                                    </SelectParameters>
                                </asp:ObjectDataSource>
                                <asp:RequiredFieldValidator ID="reqVal" runat="server" ControlToValidate="lstQuestions"
                                    Display="Dynamic" ErrorMessage="&nbsp;* Please select a question first !" ValidationGroup="Adding"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr style="color:Black;background-color:#EEEEEE;">
                            <td align="right" valign="top">
                                <asp:Button ID="butUpdate" runat="server" Text="Update Question" ValidationGroup="Adding" /><asp:Button ID="butAdd" runat="server" Text="Add Question" ValidationGroup="Adding" />&nbsp;
                                <asp:Button ID="butPreview" runat="server" Text="Preview" ValidationGroup="Adding" />&nbsp;
                                <asp:Button ID="butCancel" runat="server" CausesValidation="False" Text="Cancel" />
                                
                                </td>
                        </tr>
                    </table>
                </td>
                <td colspan="2">
                </td>
            </tr>
        </table>
    </div>
</asp:Content>

